const $ = layui.$;
export default class Seat {
  constructor(seats) {
    
    if(seats &&　typeof(seats) == "string"){
      this.seats = JSON.parse(seats);
    }else{
      this.seats = seats || [];
    }
    
    this.render();
    this.handle();
  }
  render() {
    this.template = ``;
    for(let i = 0;i < this.seats.length;i++){
        let temp = "";
        for(let j = 0;j < this.seats[i].length;j++){
            if(this.seats[i][j] == 0){
                temp += "<i class='seat_null'  >&nbsp;</i>";
            }else{
                temp += "<i class='seat_optional'  ></i>";

            }
        }
        this.template += "<tr><td>"+temp+"</td></tr>"
    }
    this.template = "<table style='margin:auto'>"+this.template+"</table>"
   
  }
  handle() {
    console.log(this.template);
    layer.open({
      type: 1,
      title: "查看座位", //不显示标题栏
      area: "500px;",
      shade: 0.6,
      id: "show_seat_dialog", //设定一个id，防止重复弹出
      btn: ["关闭"],
      btnAlign: "c",
      moveType: 1, //拖拽模式，0或者1
      content: this.template,
     
      success: function (layero) {
      },
    });
  }
}
